/*    */ package com.zimbra.qa.unittest;
/*    */ 
/*    */ import com.zimbra.cs.service.formatter.ContactCSV;
/*    */ import java.io.BufferedReader;
/*    */ import java.io.PrintStream;
/*    */ import java.io.StringReader;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import java.util.Map.Entry;
/*    */ import junit.framework.TestCase;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public final class TestContactCSV
/*    */   extends TestCase
/*    */ {
/*    */   public void testSemicolonSepWithQuotes()
/*    */     throws Exception
/*    */   {
/* 42 */     String hdr = "\"Junk with, comma\";\"Title\";\"First Name\";\"Last Name\";\"E-mail Address\";\"User 1\"";
/* 43 */     String line1 = ";;\"Di\";\"Burns\";\"di@example.test\";\"Misc comment\"";
/* 44 */     String line2 = ";;\"Su\";\"James\";\"su@example.test\";\"Street musician\"";
/* 45 */     StringReader reader = new StringReader(String.format("%s\n%s\n%s\n", new Object[] { hdr, line1, line2 }));
/* 46 */     List<Map<String, String>> contacts = ContactCSV.getContacts(new BufferedReader(reader), null);
/* 47 */     assertNotNull("getContacts return null", contacts);
/* 48 */     assertEquals("getContacts return list length", 2, contacts.size());
/* 49 */     Map<String, String> firstContact = (Map)contacts.get(0);
/* 50 */     if (4 != firstContact.size()) {
/* 51 */       for (Map.Entry<String, String> entry : firstContact.entrySet()) {
/* 52 */         System.err.println(String.format("Key=%s Value=%s", new Object[] { entry.getKey(), entry.getValue() }));
/*    */       }
/*    */     }
/* 55 */     assertEquals("getContacts returned first contact map size", 4, firstContact.size());
/*    */   }
/*    */   
/*    */ 
/*    */   public void testSemicolonSepNoQuotes()
/*    */     throws Exception
/*    */   {
/* 62 */     String hdr = "Voornaam;Achternaam;Naam;E-mailadres";
/* 63 */     String line1 = "Fred;Bloggs;Frederick Bloggs;fred@example.test";
/* 64 */     String line2 = "Blaise;Pascal;B. Pascal;blaise.pascal@example.test";
/* 65 */     StringReader reader = new StringReader(String.format("%s\n%s\n%s\n", new Object[] { hdr, line1, line2 }));
/* 66 */     List<Map<String, String>> contacts = ContactCSV.getContacts(new BufferedReader(reader), null);
/* 67 */     assertNotNull("getContacts return null", contacts);
/* 68 */     assertEquals("getContacts return list length", 2, contacts.size());
/* 69 */     Map<String, String> firstContact = (Map)contacts.get(0);
/* 70 */     if (3 != firstContact.size()) {
/* 71 */       for (Map.Entry<String, String> entry : firstContact.entrySet()) {
/* 72 */         System.err.println(String.format("Key=%s Value=%s", new Object[] { entry.getKey(), entry.getValue() }));
/*    */       }
/*    */     }
/* 75 */     assertEquals("getContacts returned first contact map size", 3, firstContact.size());
/*    */   }
/*    */   
/*    */   public void tearDown() throws Exception
/*    */   {
/* 80 */     cleanUp();
/*    */   }
/*    */   
/*    */   private void cleanUp()
/*    */     throws Exception
/*    */   {}
/*    */   
/*    */   public static void main(String[] args)
/*    */     throws Exception
/*    */   {
/* 90 */     TestUtil.runTest(TestContactCSV.class);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/TestContactCSV.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */